package moriarty.gwt.shared;

import java.io.Serializable;
import java.util.Date;

/**
 * An Objectify class for using persistent storage on the google app engine.
 * 1. Must have an @Id of type Long, long, or String (recommend Long)
 * 2. Must register class (this is done in the ObjectifyRegistrar class, which extends ContextListener)
 * 3. Add the registrar to the web.xml as a <listener>
 * @author cmoriarty
 *
 */
public class Submission extends DataStoreObject implements Serializable{
	

	//For serialization through RPC
	private static final long serialVersionUID = 5893752499074137067L;
	
	public String userName;
	public String songArtist;
	public String songName;
	public String comment;
	public String link;
	public Date date;
	
	//Objectify needs a blank constructor
	public Submission(){}
	
	public Submission(String userName, String songArtist, String songName,
			String comment, String link, Date date) {
		this.userName = userName;
		this.songArtist = songArtist;
		this.songName = songName;
		this.comment = comment;
		this.link = link;
		this.date = date;
	}
	
	public void escapeSubmission(){
		this.userName = Utils.escapeHtml(userName);
		this.songArtist = Utils.escapeHtml(songArtist);
		this.songName = Utils.escapeHtml(songName);
		this.comment = Utils.escapeHtml(comment);
		this.link = Utils.escapeHtml(link);
	}
}
